//2009/08/11 15:29:17
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

class Education
{
public:
    int minimize(string desire, vector <int> tests)
    {
		int total = 0;
		for(int i=0; i<tests.size(); i++)
		{
			total += tests[i];
		}
		if(desire == "A")
		{
			int num = 90 * (tests.size() + 1) - total;
			if(num <= 0) return 0;
			else if(num > 100) return -1;
			else return num;
		}
		else if(desire == "B")
		{
			int num = 80 * (tests.size() + 1) - total;
			if(num <= 0) return 0;
			else if(num > 100) return -1;
			else return num;
		}
		else if(desire == "C")
		{
			int num = 70 * (tests.size() + 1) - total;
			if(num <= 0) return 0;
			else if(num > 100) return -1;
			else return num;
		}
		else if(desire == "D")
		{
			int num = 60 * (tests.size() + 1) - total;
			if(num <= 0) return 0;
			else if(num > 100) return -1;
			else return num;
		}
		return -1;
    }
};
